<!DOCTYPE html>
<html lang="en">
<head>
    <%- include common/headMeta %>
    <title>中华健身俱乐部</title>
    <script type="text/javascript" src="static/new_ui/js/jquery-2.0.2.min.js"
            tppabs="http://user.lsklf.com/static/new_ui/js/jquery-2.0.2.min.js"></script>
    <link href="static/new_ui/new_css/base_v3.0.css" tppabs="http://user.lsklf.com/static/new_ui/new_css/base_v3.0.css"
          type="text/css" rel="stylesheet">
    <link  style="width:16px; height=16px;" rel="shortcut icon" href="/static/new_ui/images/logo_s.png">
    <%- include common/headLink %>
    <link rel="stylesheet" href="/stylesheets/style.css"/>
    <script type="text/javascript">
        $(function () {
            //当session 失效的时候， 点击菜单的时候  让登录页面跳出iframe
            if (top.location.href != window.location.href) {
                top.location.href = window.location.href
            }
            $("body").keydown(function (event) {
                if (event.keyCode == "13") {
                    //keyCode=13是回车键
                    $('#submit-button').click();
                }
            });
            //ie6支持
            $("body").keypress(function (event) {
                if (event.keyCode == "13") {
                    //keyCode=13是回车键
                    $('#submit-button').click();
                }
            });
        });
//        function validForm() {
//            var username = $("#account").val();
//            var password = $("#password").val();
//            var autologin = $("#autologin").val();
//            if (username == "undefined" || username == "") {
//                $("#errorMsg").html("登录名不能为空！").removeClass("none");
//                $("#account").focus();
//                return;
//            }
//            if (username.length < 2 || username.length > 15) {
//                $("#errorMsg").html("登录名长度介于2至15之间！").removeClass("none");
//                $("#account").focus();
//                return;
//            }
//            if (password == "undefined" || password == "") {
//                $("#errorMsg").html("密码不能为空！").removeClass("none");
//                $("#password").focus();
//                return;
//            }
//            if (password.length < 6 || password.length > 20) {
//                $("#errorMsg").html("密码长度介于6至20之间！").removeClass("none");
//                $("#password").focus();
//                return;
//            }
//            $.ajax({
//                type: "post",
//                url: "login.htm"/*tpa=http://user.lsklf.com/login.htm*/,
//                data: {"account": username, "password": password, "autologin": autologin},
//                success: function (data, textStatus) {
//                    if (data.success) {
//                        $("#errorMsg").html("");
//                        window.location.href = data.msg;
//                    }
//                    else {
//                        $("#password").val("");
//                        $("#errorMsg").html(data.msg).removeClass("none");
//                    }
//                },
//                error: function () {
//                }
//            });
//        }
        $(function () {
            var $input = $(".ueser_pass").find("input");
            var $btn = $(".auto_login").find(".choic_d");
            $input.on('click', function () {
                $(this).parents("p").css({border: '1px solid #16AC4E'})
                $(this).parents("p").siblings("p").css({border: '1px solid transparent'})
            });
            $btn.on('click', function () {
                var $em = $(this).parents("p").find(".choic_d:first-child")
                if ($em.hasClass("ok")) {
                    $em.removeClass("ok");
                    $("#autologin").val("false");
                } else {
                    $em.addClass("ok");
                    $("#autologin").val("true");
                }
            })
        })
    </script>
</head>
<body class="login_bg">
<div class="conts">
    <div class="icon">
        <img src="static/new_ui/images/yoga.png" tppabs="http://user.lsklf.com/static/new_ui/images/yoga.png"
             alt=""/>
    </div>
    <div class="go_input">
        <div class="font">
            <img src="static/new_ui/images/login_font.png"
                 tppabs="http://user.lsklf.com/static/new_ui/images/login_font.png" alt=""/>
        </div>
        <div class="ueser_pass">
            <input id="autologin" name="autologin" type="hidden" value="true"/>

            <p><em class="ueser"></em><input type="text" id="account" name="account" placeholder="用户名"/></p>

            <p><em class="password"></em><input type="password" id="password" name="password" placeholder="密码"
                                                style="text-indent:10px "/></p>
            <span class="error" id="errorMsg"></span>

            <p class="auto_login"><em class="auto ok choic_d"></em>&nbsp;&nbsp;<span
                        class="auto_font choic_d">自动登录</span></p>
        </div>
        <div class="sub_btn">
            <button  id="submit-button" class="button btn-success btn-w210">登录</button>
            <!--<a href="/cus" class="button btn-success btn-w210">登录</a>-->
        </div>
    </div>
    <div class="company_info">
        <p>Copyright©2015-2016 中华健身俱乐部有限公司版权所有</p>

        <p>中华健身俱乐部有限公司</p>
    </div>
</div>
<script>
    KISSY.use('dom, node, event, io, tipmask', function (S, DOM, Node, Event, IO, TipMask) {

        var $ = S.all,
                _event = S.Event;

        _event.on('#submit-button', 'click', function () {

            var name = $('#account').val(),
                    password = $('#password').val();

            if(!name){

                new TipMask({
                    title: '温馨提示',
                    text: '请输入用户名！'
                });

                return false;

            }

            if(!password){

                new TipMask({
                    title: '温馨提示',
                    text: '请输入密码！'
                });

                return false;

            }

            new IO({
                type: 'post',
                url: '/login',
                data: {
                    name: name,
                    password: password
                },
                success: function (data) {

                    if(!data.isChecked){

                        new TipMask({
                            title: '温馨提示',
                            text: data.text
                        });

                    } else {
                        location.href= '/';
                    }

                }

            });

        });

    });
</script>
</body>
</html>